package com.noble.glamour.ui.fragment.video;

import android.content.Context;
import android.graphics.Rect;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.noble.glamour.R;
import com.noble.glamour.module.util.UIShow;
import com.noble.library.view.base.BasePanel;

import java.util.ArrayList;
import java.util.List;

/**
 * 女性视频集：录制视频
 * Created by Su on 2017/11/13.
 */
public class VideoRecordPanel extends BasePanel implements View.OnClickListener {
    private RecyclerView recyclerView;
    private VideoIssueAdapter adapter;

    public VideoRecordPanel(Context context) {
        super(context);
        setContentView(R.layout.video_record_panel);
        initView();
    }

    private void initView() {
        recyclerView = (RecyclerView) findViewById(R.id.record_issue);
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        recyclerView.addItemDecoration(new ItemSpaces());
        adapter = new VideoIssueAdapter();
        recyclerView.setAdapter(adapter);

        findViewById(R.id.btn_record).setOnClickListener(this);

        // TODO Test
        List<String> dataList = new ArrayList<>();
        dataList.add("短问题");
        dataList.add("短短问题一");
        dataList.add("问题一短短问题一");
        dataList.add("问题一问题一短短问题一");
        dataList.add("问题一问题一问题一短短问题一");
        dataList.add("问题一问题一问题一问题一短短问题一");
        dataList.add("问题一问题一问题一问题一问题一短短问题一");
        dataList.add("问题一问题一问题一问题一问题一问题一短短问题一");
        dataList.add("问题一问题一问题一问题一问题一问题一问题一短短问题一");
        dataList.add("问题一问题一问题一问题一问题一问题一问题一问题一短短问题一");
        adapter.setList(dataList);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_record:
                UIShow.showPLRecordActivity(getContext());
                break;
        }
    }

    // RecyclerView margin
    private class ItemSpaces extends RecyclerView.ItemDecoration {

        @Override
        public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
            super.getItemOffsets(outRect, view, parent, state);
            outRect.bottom = 30;
        }
    }
}
